package com.zh.note.huawei.onehundred.AI识别面板;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @Author: zhanghuan
 * @date: 2023/9/5 09:12
 * @description: create it
 * <p>
 * 5
 * 1 0 0 2 2
 * 2 6 1 8 3
 * 3 3 2 5 4
 * 5 5 4 7 6
 * 4 0 4 2 6
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        // 存储数据
        int[][] lights = new int[n][3];
        // 半径长度
        int radius = 0;
        for (int i = 0; i < n; i++) {
            String[] input = sc.nextLine().split(" ");
            int id = Integer.parseInt(input[0]);
            int x1 = Integer.parseInt(input[1]);
            int y1 = Integer.parseInt(input[2]);
            int x2 = Integer.parseInt(input[3]);
            int y2 = Integer.parseInt(input[4]);
            lights[i] = new int[]{id, (x1 + x2) / 2, (y1 + y2) / 2};
            radius = (x2 - x1) / 2;
        }
        //按照高度排序
        Arrays.sort(lights, Comparator.comparingInt(a -> {
            return a[2];
        }));
        StringBuilder sb = new StringBuilder();
        int rowStartIndex = 0;
        for (int i = 0; i < n; i++) {
            if (lights[i][2] - lights[rowStartIndex][2] > radius) {
                //rowStartIndex, i 之间元素进行排序
                Arrays.sort(lights, rowStartIndex, i, Comparator.comparingInt(a -> a[1]));
                for (int j = rowStartIndex; j < i; j++) {
                    sb.append(lights[j][0]).append(" ");
                }
                rowStartIndex = i;
            }
        }
        //剩余的排序
        Arrays.sort(lights, rowStartIndex, n, Comparator.comparingInt(a -> a[1]));
        for (int i = rowStartIndex; i < n; i++) {
            sb.append(lights[i][0]).append(" ");
        }
        System.out.println(sb.toString().trim());

    }
}
